<?php
require_once 'includes/image_resizer.php'; 
require_once 'includes/class.phpmailer.php';
require_once "includes/class/member_management.class.php";

$smsg="";
if($_SESSION['user_id_sess']=="") {
	echo "<script type='text/javascript'> window.location='index.php?signin'; </script>";
}
$userId = $_SESSION['user_id_sess'];
$userType = $_SESSION['user_type_sess'];
$editlist = $_GET['editlist'];
$sb_flag = 0;
$sqlSelNoSeller="SELECT * FROM tbl_items where product_id='$editlist' and seller_id!='$userId'";
$rstSelNoSeller=mysql_query($sqlSelNoSeller);				
$numSelNoSeller=mysql_num_rows($rstSelNoSeller);
if($numSelNoSeller > 0)
{
	$sb_flag = 1;
	while($data_no_seller = mysql_fetch_array($rstSelNoSeller))
	{
		if($data_no_seller['seller_id']=='68') //if seller is swapen buddy
		$sb_flag = 0;
	}
}
if(!empty($_REQUEST['keyword']))
{
	$curProId = $_REQUEST['keyword'];
	$today			=	date("Y-m-d G:i:s",time());
	//$duration		=	$_REQUEST['pro_duration'];
	$bargainDuration 	= 	date("Y-m-d G:i:s",time() + ($duration * 24 * 60 * 60));		
	
	$bargain_price_option	=	sanitize($_REQUEST['bargain_price_option']);
	$localPickup		=	sanitize($_REQUEST['localPickup']);
	$bargain_commission_option = 	sanitize($_REQUEST['bargain_commission_option']);
	$amazon_name		=	sanitize($_REQUEST['amazon_name']);
	$gift_name 		=	sanitize($_REQUEST['gift_name']);
	$gift_description	=	$_REQUEST['gift_description'];
	//$gift_image		=	$_REQUEST['gift_image'];
	
	$pro_name		=	sanitize($_REQUEST['pro_name']);	
	$category		=	"";
	$pro_quantity		=	sanitize($_REQUEST['pro_quantity']);
	//$sell_type		=	sanitize($_REQUEST['sell_type']);
	$sell_by		=	sanitize($_REQUEST['sell_by']);
	$pro_condition 		= 	sanitize($_REQUEST['pro_condition']);
	$pro_commission 	= 	sanitize($_REQUEST['pro_commission']);
	$pro_commission		=	str_replace("$","",$pro_commission);
	$shipStatus		=	sanitize($_REQUEST['ship_status']);
	//$ship_service		=	$_REQUEST['ship_service'];
	
	$pro_shipping		=	sanitize($_REQUEST['pro_shipping']);
	$pro_policy		=	sanitize($_REQUEST['pro_policy']);
	$pro_courior		=	sanitize($_REQUEST['pro_courior']);
	$sales_tax		=	sanitize($_REQUEST['sales_tax']);
	$sales_tax		=	str_replace("$","",$sales_tax);
	if($shipStatus) {
		$shipping 	= 	"Free";
	}
	else {
		$shipping 	= 	sanitize($_REQUEST['pro_ship']);
		$shipping	=	str_replace("$","",$shipping);
	}
	
	if($_REQUEST['pro_sub_subcategory']!="") {
		$category	=	sanitize($_REQUEST['pro_sub_subcategory']);
	}
	else {
		$category	=	sanitize($_REQUEST['pro_subcategory']);
	}	
	
	$pro_price		=	sanitize($_REQUEST['pro_price']);	
	$pro_price		=	str_replace("$","",$pro_price);	
	$pro_description	=	sanitize($_REQUEST['pro_description']);	
	$remarks		=	sanitize($_REQUEST['remarks']);
	$pro_description=$_REQUEST['pro_description'];	
	
	if($localPickup==1)
		$sell_type	=	"local";
	else if($localPickup==1 && $shipping!='')
		$sell_type	=	"both";
	else
		$sell_type	=	"online";
	
	/*if($_REQUEST['pro_sub_subcategory']!="") {
		$category=$_REQUEST['pro_sub_subcategory'];
	}
	else {
		$category=$_REQUEST['pro_subcategory'];
	}*/
	//$sql_adddel="DELETE from tbl_items_code 				
//				where product_id='$curProId'";				
//	$rst_adddel=mysql_query($sql_adddel);
	//Om
	
	$counter=count(sanitize($_REQUEST['code']));
	$items_code=array();
	$items_code=sanitize($_REQUEST['code']);
	
	$counter=count($items_code);
	
	for($k=0;$k<$counter;$k++)
	{
		if($counter-1==$k)
		{
			$strIDs .="'".$items_code[$k]."'";
		}
		else
		{
			$strIDs .="'".$items_code[$k]."',";
		}
	}
	
	//$sqlInsItem = "delete from tbl_items_code where product_id='$curProId' and isSold='0' and isWhole='0' and code not in ($strIDs) ";				
	
	$sqlInsItem = "delete from tbl_items_code where product_id='$curProId' and isSold='0' and code not in ($strIDs) ";				
	
	$rstInsItem = mysql_query($sqlInsItem);	
	
	for($j=0;$j<$counter;$j++)
	{
		$sqlSelCodes = "SELECT * FROM tbl_items_code WHERE product_id='$curProId' and code='".$items_code[$j]."' ";
		$rstSelCodes = mysql_query($sqlSelCodes);
		$rowSelCodes = mysql_fetch_array($rstSelCodes);
		if(!is_array($rowSelCodes))
		{
			$sqlInsItem = "INSERT INTO tbl_items_code(code,product_id,item_id,owner_id,isSold,sell_by,isWhole) VALUES ";
			if($items_code[$j]!="")
			{
				$sqlInsItem .="('".$items_code[$j]."','$curProId','0',".$_SESSION['user_id_sess'].",'0',0,0)";			
			}
			else
			{
				$sqlInsItem .="(".rand(1000000000,9999999999).",'$curProId','0',".$_SESSION['user_id_sess'].",'0',0,0)";		
			}	
			$rstInsItem = mysql_query($sqlInsItem);			
		}		
	}
	//$list=implode(",",$items_code);
	
	
	//print_r($items_code);
	
	//echo $strIDs;
	
	
	//Om		
	//print_r($_REQUEST['code']);
	//exit();
	
	
	if($sb_flag==0)
	{
		$sql_addpro="UPDATE tbl_product set 
				quantity='$pro_quantity',
				bargain_price_option='$bargain_price_option',
				bargain_commission_option='$bargain_commission_option'
				where product_id='$curProId'";
		$rst_addpro=mysql_query($sql_addpro);
		//exit();
	}
	else
	{
		$sql_addpro="UPDATE tbl_product set 
				quantity='$pro_quantity',
				category_id='$category',
				product_name='$pro_name',
				product_description='$pro_description',
				shipping='$shipping' ,	
				product_price='$pro_price' ,
				duration='$pro_duration' ,	
				commission='$pro_commission',
				pro_condition='$pro_condition',
				sales_tax='$sales_tax',
				selling_type='$sell_type',
				remarks='$remarks',
				bargain_price_option='$bargain_price_option',
				localPickup='$localPickup',
				bargain_commission_option='$bargain_commission_option',
				gift_name='$gift_name',
				return_id='$pro_policy',
				shipping_id='$pro_shipping',
				courior_id='$pro_courior',
				gift_description='$gift_description'
				where product_id='$curProId'";
				
		$rst_addpro=mysql_query($sql_addpro);
		$upd_user=mysql_query("UPDATE tbl_users set amazon_email='$amazon_name' where user_id='".$_SESSION['user_id_sess']."'") or die(mysql_error());
	}
	$pro_id = $curProId;
	
	
	 $subject="Product edited by owner";
	 $sqlEmail="select * from tbl_emails where email_type='Edit Product'";
	 $resEmail=mysql_query($sqlEmail);
	 $rowEmail=mysql_fetch_array($resEmail);
	 
	 $arrUser=mysql_fetch_array(mysql_query("select * from tbl_users where user_id='".$_SESSION['user_id_sess']."'"));
	 
	 $sqlSeller="SELECT * FROM tbl_items where product_id='".$pro_id."'";
	 $exeSeller=mysql_query($sqlSeller) or die(mysql_error());
	 while($arrSeller=mysql_fetch_array($exeSeller)) 
	 {
		 $selUser=mysql_fetch_array(mysql_query("select * from tbl_users where user_id='".$arrSeller['seller_id']."'"));
		 $fullname=$selUser['first_name']." ".$selUser['last_name'];
		 
		 $selOwner=mysql_fetch_array(mysql_query("select * from tbl_users where user_id='".$arrSeller['owner_id']."'"));
		 
		 $message=str_replace('%fname%',$selUser['first_name'],str_replace('%lname%',$selUser['last_name'],str_replace('%pname%',$pro_name,str_replace('%username%',$selOwner['username'],$rowEmail['email_body']))));
		 $headers = "From: Swapen.com<mail@swapen.com> \r\n";
		 $headers .= 'MIME-Version: 1.0' . "\r\n";
		 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
		 mail($selUser['email'],$subject, $message, $headers);
	 }

	$gift_image=pathinfo($_FILES["gift_image"]["name"]);	
	if(!empty($gift_image['extension'])) {
		if(strtolower($gift_image['extension'])=="jpeg" || strtolower($gift_image['extension'])=="jpg" || strtolower($gift_image['extension'])=="png" || strtolower($gift_image['extension'])=="gif") {
			$orgname1=mt_rand();				
			$type1=$gift_image['extension'];				
			$path1="products/original/".$orgname1.$pro_id.".".$type1;								
			
			$path_thumb1="products/thumb/".$orgname1.$pro_id."_thumb.".$type1;						
			
			$path_medium1="products/medium/".$orgname1.$pro_id."_medium.".$type1;				
			
			move_uploaded_file($_FILES["gift_image"]["tmp_name"],$path1);				  
			productResize($path1, $path_thumb1, $path_medium1, $type1);	
			$imagePath1 = 	$path1;
		}
		$ql = mysql_query("UPDATE tbl_product SET gift_image='$path1' WHERE product_id=$pro_id") or die(mysql_error);
	}
	
	if($sb_flag==0)
	{
		$sql_addpro1="UPDATE tbl_items set 
				quantity='$pro_quantity'				
				where product_id='$curProId' and seller_id='$userId'";
				
		$rst_addpro1=mysql_query($sql_addpro1);
	}
	else
	{
		$sql_addpro1="UPDATE tbl_items set 
				quantity='$pro_quantity',
				product_description='$pro_description',
				price='$pro_price' ,
				commission='$pro_commission' ,	
				remarks='$remarks'				
				where product_id='$curProId' and seller_id='$userId'";
				
		$rst_addpro1=mysql_query($sql_addpro1);
	}
	//setup for auto email
					$sqlEmail="select * from tbl_emails where email_type='Item Edited'";
					$resEmail=mysql_query($sqlEmail);
					$rowEmail=mysql_fetch_array($resEmail);
					
					$sqlSellers="select * from tbl_items ti, tbl_users tu where tu.user_id=ti.seller_id and ti.product_id='".$curProId."'";
					$resSellers=mysql_query($sqlSellers);
					while($rowSellers=mysql_fetch_array($resSellers))
					{
					$subj=str_replace('##_ItemName',$_POST['itemname'],$rowEmail['email_subject']);
					$emailContent=str_replace('##_MerchantName',$rowSellers['username'],$rowEmail['email_body']);
					$emailContent=str_replace('##_ItemName',$_POST['itemname'],$emailContent);
	  $mailmsg="<table width='100%' border='0' style='font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px; line-height:25px'>
  <tr>
    <td width='18%' height='41'><table width='100%' border='0'>
      <tr>
        <td width='19%' height='68'><img src='".$base_url."images/logo.gif'></td>
        <td width='81%'> </td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height='32' colspan='2' style='font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;'>".$emailContent."</td>
  </tr>
  
 
</table>
";
		$mail = new PHPMailer(); // defaults to using php "mail()"
	  	$mail->MsgHTML($mailmsg);
		$mail->From       = "mail@swapen.com";
		$mail->FromName   = "Swapen.com";
		$mail->Subject    = $subj;
		$mail->AddAddress($rowSellers['email'], $firstName);
		$mail->Send();
					}
	//check product entry in tbl_product_images
	$sqlChk = "SELECT product_id FROM tbl_product_images WHERE product_Id='$curProId' AND  product_type='p'";
	$rstChk = mysql_query($sqlChk) or die(mysql_error());
	if(mysql_num_rows($rstChk)==0) {
		$sqlInsEntry = "INSERT INTO tbl_product_images SET product_id='$curProId', product_type='p'";
		$rstInsEntry = mysql_query($sqlInsEntry) or die(mysql_error()); 
	}
	
	if($rst_addpro) {
		$smsg="true";
		$pro_id=$curProId;
		
		$imgPaths = getImagePath($pro_id); 
		
		for($i=1; $i<=5;$i++) {
			$pro_image[$i]=pathinfo($_FILES["pro_image".$i]["name"]);	
					
			if(!empty($pro_image[$i]['extension'])) {
				if(strtolower($pro_image[$i]['extension'])=="jpeg" || strtolower($pro_image[$i]['extension'])=="jpg" || strtolower($pro_image[$i]['extension'])=="gif") {
					
					/* if($imgPaths!="") {															
							if($imgPaths['product_image_'.$i]!="") { unlink($imgPaths['product_image_'.$i]); }
							if($imgPaths['product_sample_'.$i]!="") { unlink($imgPaths['product_sample_'.$i]); }
							if($imgPaths['product_thumbnail_'.$i]!="") { unlink($imgPaths['product_thumbnail_'.$i]); }
						
					} */
						
					$orgname[$i]=mt_rand();				
					$type[$i]=$pro_image[$i]['extension'];				
					$path[$i]="products/original/".$orgname[$i].$pro_id.".".$type[$i];								
					
					$path_thumb[$i]="products/thumb/".$orgname[$i].$pro_id."_thumb.".$type[$i];						
					
					$path_medium[$i]="products/medium/".$orgname[$i].$pro_id."_medium.".$type[$i];				
					
					move_uploaded_file($_FILES["pro_image".$i]["tmp_name"],$path[$i]);				  
					productResize($path[$i], $path_thumb[$i], $path_medium[$i], $type[$i]);	
					$imagePath[] = 	$path[$i];	
					$mediumPath[] = $path_medium[$i];	
					$thumbPath[] = 	$path_thumb[$i];	
					$sql_updpro="UPDATE tbl_product_images set list_type='1',					
								 product_thumbnail_$i='".$path_thumb[$i]."',
								 product_sample_$i='".$path_medium[$i]."',
								 product_image_$i='".$path[$i]."'
								 where product_id=$pro_id AND product_type='p'";	
					$rst_updpro=mysql_query($sql_updpro) or die(mysql_error());
					
					
					
					if(mysql_affected_rows()>0) {
						
					}
					else { $smsg="false"; }		
				}
			}
		 } //end of for
		 echo "<script type='text/javascript'> window.location='index.php?mySwapen'; </script>";
	}
	else { $smsg="false"; }	
}


$proId = $_GET['editlist'];
$owner = getProductOwner($proId);

if($userId!=$owner[0]) {
	echo "<script type='text/javascript'> window.location='index.php?mylist'; </script>";
}

$sqlSelPro = "SELECT * FROM tbl_product where product_id='$proId'";
$rstSelPro = mysql_query($sqlSelPro) or die(mysql_error());
$rowSelPro = mysql_fetch_array($rstSelPro);
//echo "select parent_id from tbl_category where category_id='".$rowSelPro['category_id']."'";
$qry = mysql_query("select parent_id from tbl_category where category_id='".$rowSelPro['category_id']."'") or die(mysql_error());
$category   =   mysql_fetch_array($qry);
$parent_id  =   $category['parent_id'];

$qry_sub_cat = mysql_query("select * from tbl_category where parent_id='".$parent_id."'") or die(mysql_error());

$selimage="SELECT * from tbl_product_images where product_id=$proId AND product_type='p'";
$rstselimage=mysql_query($selimage);
$rowselimage=mysql_fetch_array($rstselimage);

//$cId = getCategory($rowSelPro['category_id']);

//Om
$sqlSelCodes = "SELECT GROUP_CONCAT(code SEPARATOR ',' ) AS Codes,GROUP_CONCAT(isSold SEPARATOR ',' ) AS Sold  FROM tbl_items_code WHERE product_id='$proId' order by code_id asc ";
$rstSelCodes = mysql_query($sqlSelCodes);
$rowSelCodes = mysql_fetch_array($rstSelCodes);

$first_value="";
if(is_array($rowSelCodes))
{
	$array_keys=array();
	$array_keys=explode(",",$rowSelCodes['Codes']);
	$first_value=$array_keys[0];
	
}
//Om
//print_r($rowSelCodes);
//exit;
$usrObj = new member_management;
$userInfo = $usrObj->getMemberById($userId);

$amazonaccnt="";

if($userInfo['amazon_email']!="")
 $amazonaccnt=$userInfo['amazon_email'];
?>

<script src="<?php echo $base_url?>js/jquery-1.4.4.js" type="text/javascript"></script>
<script src="<?php echo $base_url?>js/jquery.custom_radio_checkbox.js" type="text/javascript"></script>


<script language="javascript" type="text/javascript">
$(document).ready(function(){
	$(".radio").dgStyle();
	$(".checkbox").dgStyle();
	
	toggle_bargain_img(<?php echo $rowSelPro['bargain_price_option'];?>);
	toggle_bargain_c_img(<?php echo $rowSelPro['bargain_commission_option'];?>);
	projected_profit();
	
	<?php
	
		if($sb_flag==1)
		{
		?>
			$('#pro_subcategory').attr('disabled','disabled');
			$('#pro_sub_subcategory').attr('disabled','disabled');
			$('#pro_name').attr('disabled','disabled');
			$('#pro_image1').attr('disabled','disabled');
			$('#pro_image2').attr('disabled','disabled');
			$('#pro_image3').attr('disabled','disabled');
			$('#pro_image4').attr('disabled','disabled');
			$('#pro_image5').attr('disabled','disabled');
			$('#pro_description').attr('disabled','disabled');
			//$('#pro_description').setEnabled(false);

			$('#pro_price').attr('disabled','disabled');
			$('#pro_courior').attr('disabled','disabled');
			$('#pro_ship').attr('disabled','disabled');
			$('#ship_status').attr('disabled','disabled');
			$('#localPickup').attr('disabled','disabled');
			$('#pro_condition').attr('disabled','disabled');
			$('#pro_commission').attr('disabled','disabled');
			$('#state').attr('disabled','disabled');
			$('#sales_tax').attr('disabled','disabled');
			$('#pro_policy').attr('disabled','disabled');
			$('#remarks').attr('disabled','disabled');
			$('#amazon_name').attr('disabled','disabled');
			$('#gift_name').attr('disabled','disabled');
			$('#gift_description').attr('disabled','disabled');
			$('#gift_image').attr('disabled','disabled');	
		<?php
		}
	
	?>
});
</script>
<style type="text/css">
	#sell-form { border:0px solid #CCC; vertical-align:top; padding:10px; float:left; width:93%; margin:2%; }

	#sell-form label{
	float: left;
	width: 130px;
	font-weight: bold;
	}
	
	#sell-form input, select, textarea{	
	width: 280px;
	margin-bottom: 5px;
	font-size:12px;
	}
	
	#sell-form textarea{
	height: 250px;
	width: 450px;
	font-size:12px
	}
	

	#sell-form #submitbutton{
	margin-left: 130px;
	margin-top: 5px;
	width: 90px;
	}
	
	#sell-form #sellby-div { float:left;  }
	
	#sell-form #sellby-div label { width: 70px; margin-bottom:2px; font-weight:normal; }
	#sell-form #sellby-div input { width: 1px; }
	
	#sell-form br{
	clear: left;
	}

	.whitebox950 {
		float:left;
		width:950px;
	}
	
	.whitebox940_top {
		background: url(images/whitebox_top_940.png) no-repeat scroll 0 0 transparent;
		float: left;
		height: 36px;
		margin: 0;
		padding: 0;
		width: 940px;
	}
	
	.whitebox940_bottom {
		background: url(images/whitebox_bottom_940.png) no-repeat scroll 0 0 transparent;
		float: left;
		height: 36px;
		margin: 0;
		padding: 0;
		width: 940px;
	}
	
	.whitebox940_repeat {
		background: url(images/whitebox_repeat_940.png) repeat-y scroll 0 0 transparent;
		float: left;
		margin: 0;
		padding: 0;
		width: 940px;
		
	}
	
	.blue_box_big {
	float:left;
	width:935px;
	margin: 0px 0px 0px 3px;
	}
	.bluebar_left_big {
	background:url(images/register_images/bluebar_left.png) no-repeat;
	width:19px;
	height:52px;
	float:left;
	margin:0px 0px 0px 0px;
	padding:0;
	}
	.bluebar_center_big {
	background:url(images/register_images/bluebar_repeat.png) repeat-x;
	height:52px;
	width:895px;
	float:left;
	text-align:center;
	
	}
	
	.bluebar_right_big {
	background:url(images/register_images/bluebar_right.png) no-repeat;
	width:19px;
	height:52px;
	float:left;
	}
	
	.bluebar_center_big span {
	float: left;
	padding: 15px;
	width: 95%;
	}
	
	.form_field_big {
	float: left;
	/*height: 40px;*/
	padding: 7px;
	width: 870px;
	}
	
	.form_field_big a {
		text-decoration:none;
	}
	
	.form_field_big label {
	color: #666666;
	float: left;
	padding: 6px 3px 6px 0;
	text-align: left;
	width: 150px;
	font-weight:bold;
	}
	
	.inner_round_box {
		float: left;
		margin: 5px 18px;
		width: 96%;
		border: 1px solid #b5b5b5; -moz-border-radius: 7px 7px 7px 7px;
	}
	
	.btn_uplimg_left {
		width:10px;
		height:36px;
		background:url(images/button_left_07.png) no-repeat;
		float:left;
	}
	
	.btn_uplimg_repeat {
		float:left;
		height:36px;
		background:url(images/button_repeat_07.png) repeat-x;
	}
	
	.btn_uplimg_right {
		width:10px;
		height:36px;
		background:url(images/button_right_07.png) no-repeat;
		float:left;
	}
</style>

<script language="javascript" src="js/ajaxbase.js" type="text/javascript"></script>
<script language="javascript" src="js/add_row.js" type="text/javascript"></script>
<div id='panel'>
<table width="100%" border="0">

	<tr>
	  	<td><?php if($smsg=="true") { echo "<div id='suc-msg'> Product updated successfully... </div>"; } ?></td>
	</tr>  
	<tr>
		<td>
		<form name="form1" id="form1" method="post" action="" enctype="multipart/form-data"  onsubmit="return validateForm();">
			<div class="whitebox950">
				<div class="fullbox2_top"></div>
				<div class="fullbox2_repeat">
					<div class="blue_box_big" align="center">
						<img src="<?php echo $base_url;?>images/edit_ur_product_listing.png" /><br />
						<font style="color:#B7B5B5;">Edit your existing product details here. </font>
						<br />&nbsp;
					</div>
					
					<div class="blue_box_big">
						<div class="bluebar_left_big"></div>
						<div class="bluebar_center_big"><span>Choosen Category</span></div>
						<div class="bluebar_right_big"></div>
					</div>
					
					<div class="inner_round_box">
						<div class="form_field_big">
							<label for="pro_subcategory" id="lblpro_subcategory">Category</label><br /><br />
							<select name="pro_subcategory" id="pro_subcategory" onChange="getSubSubCat(this.value,'sub-sub-category');" class="inputbg" style="width:280px;">
							<option value="">Select Category</option>
							<?php				
							$sql_shocat="SELECT * FROM tbl_category where parent_id='1'";
							$rst_shocat=mysql_query($sql_shocat);
							while($row_shocat=mysql_fetch_array($rst_shocat)) {
								 $cat_id=$row_shocat['category_id'];
								 $cat_name=$row_shocat['category_name'];							 
								 echo "<option value='$cat_id'>$cat_name</option>";
							}
							?>
							</select><script>$('#pro_subcategory').val(<?php echo $parent_id;?>);</script>
							<span id="loader-div1"></span>
						</div>
						
						<div class="form_field_big" id="sub-sub-category">
							<label for="pro_sub_subcategory" id="lblpro_sub_subcategory">Sub Category</label><br /><br />
							<select name="pro_sub_subcategory" id="pro_sub_subcategory" class="inputbg" style="width:280px;">
								<option value="">..Select subcategory..</option>
								<?
								while($sub_cat=mysql_fetch_array($qry_sub_cat)) {
									?>
									<option value="<?php echo $sub_cat['category_id']; ?>"><?php echo $sub_cat['category_name']; ?></option>
									<?php
								}
								?>
							</select><script>$('#pro_sub_subcategory').val(<?php echo $rowSelPro['category_id'];?>);</script><br>
						</div>
					
					</div>
					<div class="inner_round_box">
						<div class="form_field_big">
							<b>Buyers will locate your item better with a good descriptive listing name</b>
							<br />
							<label for="pro_name" id="lblpro_name">Listing Name</label><br /><br />
							<span>
								
								<input type="text" style="width: 400px; float:left;" class="inputbg" id="pro_name" name="pro_name" value="<?php echo $rowSelPro['product_name'];?>" />
								
							</span>
							<font style="font-size:10px; color:#636060;">
								<b>Re-called items:</b> It is solely your responsibility to make sure your item has not be recalled. If you are unsure please check <a href="http://www.recalls.gov" target="_blank">here</a>
							</font>
						</div>
					</div>
					<div class="inner_round_box">
						<div class="form_field_big">
							<b>Add free images to make your listing stand out</b>
							<br /><br />
							<label for="pro_image1">Product Image 1</label><br /><br /><br />
							<input type="file" name="pro_image1" id="pro_image1" style="float:left;" class="inputbg" />
						</div>
						<div class="form_field_big">
							<label for="pro_image2">Product Image 2</label><br /><br /><br />
							<input type="file" name="pro_image2" id="pro_image2" style="float:left;" class="inputbg" />
						</div>
						<div class="form_field_big">
							<label for="pro_image3">Product Image 3</label><br /><br />
							<input type="file" name="pro_image3" id="pro_image3" style="float:left;" class="inputbg" />
							
						</div>
						<div class="form_field_big">
							<label for="pro_image4">Product Image 4</label><br /><br /><br />
							<input type="file" name="pro_image4" id="pro_image4" style="float:left;" class="inputbg" />
						</div>
						<div class="form_field_big">
							<label for="pro_image5">Product Image 5</label><br /><br /><br />
							<input type="file" name="pro_image5" id="pro_image5" style="float:left;" class="inputbg" />
						</div>
						
						<div class="form_field_big">
							
							<div style="float:left; width:50px;">&nbsp;</div><!--This div is to give some blank space before button 1 starts-->
							
							<?
							if(!empty($rowselimage['product_image_1']))
							{
								$img1 = explode("/",$rowselimage['product_image_1']);
								$img1 = $img1[2];
							}
							else
							{
								$img1 = ''; 
							}
							
							?>
							
							<div style="float:left; margin-bottom:-10px; margin-right:10px;" title="<?php echo $img1;?>">
								<div class="btn_uplimg_left"></div>
								<div class="btn_uplimg_repeat">
									<label style="width:100px; text-align:center; font-weight:bold; margin-top:5px;">Image 1
									<?
									if(!empty($rowselimage['product_image_1'])) {
									?>
									<img src="images/success.gif" align="absmiddle" />
									<?
									}
									?>
									</label>
								</div>
								<div class="btn_uplimg_right"></div>
							</div>
						
							<?
							 
							if(!empty($rowselimage['product_image_2']))
							{
								$img2 = explode("/",$rowselimage['product_image_2']);
								$img2 = $img2[2];
							}
							else
							{
								$img2 = ''; 
							}
							
							?>
							<div style="float:left; margin-bottom:-10px; margin-right:10px;" title="<?php echo $img2;?>">
								<div class="btn_uplimg_left"></div>
								<div class="btn_uplimg_repeat">
									<label style="width:100px; text-align:center; font-weight:bold; margin-top:5px;">Image 2
									<?
									if(!empty($rowselimage['product_image_2'])) {
									?>
									<img src="images/success.gif" align="absmiddle" />
									<?
									}
									?>
									</label>
								</div>
								<div class="btn_uplimg_right"></div>
							</div>
					
							<?
							if(!empty($rowselimage['product_image_3']))
							{
								$img3 = explode("/",$rowselimage['product_image_3']);
								$img3 = $img3[2];
							}
							else
							{
								$img3 = ''; 
							}
							
							?>
							<div style="float:left; margin-bottom:-10px; margin-right:10px;" title="<?php echo $img3;?>">
								<div class="btn_uplimg_left"></div>
								<div class="btn_uplimg_repeat">
									<label style="width:100px; text-align:center; font-weight:bold; margin-top:5px;">Image 3
									<?
									if(!empty($rowselimage['product_image_3'])) {
									?>
									<img src="images/success.gif" align="absmiddle" />
									<?
									}
									?>
									</label>
								</div>
								<div class="btn_uplimg_right"></div>
							</div>
				
							<?
							if(!empty($rowselimage['product_image_4']))
							{
								$img4 = explode("/",$rowselimage['product_image_4']);
								$img4 = $img4[2];
							}
							else
							{
								$img4 = ''; 
							}
							
							?>
							<div style="float:left; margin-bottom:-10px; margin-right:10px;" title="<?php echo $img4;?>">
								<div class="btn_uplimg_left"></div>
								<div class="btn_uplimg_repeat">
									<label style="width:100px; text-align:center; font-weight:bold; margin-top:5px;">Image 4
									<?
									if(!empty($rowselimage['product_image_4'])) {
									?>
									<img src="images/success.gif" align="absmiddle" />
									<?
									}
									?>
									</label>
								</div>
								<div class="btn_uplimg_right"></div>
							</div>
							<?
							if(!empty($rowselimage['product_image_5']))
							{
								$img5 = explode("/",$rowselimage['product_image_5']);
								$img5 = $img5[2];
							}
							else
							{
								$img5 = ''; 
							}
							
							?>
							<div style="float:left; margin-bottom:-10px; margin-right:10px;" title="<?php echo $img5;?>">
								<div class="btn_uplimg_left"></div>
								<div class="btn_uplimg_repeat">
									<label style="width:100px; text-align:center; font-weight:bold; margin-top:5px;">Image 5
									<?
									if(!empty($rowselimage['product_image_5'])) {
									?>
									<img src="images/success.gif" align="absmiddle" />
									<?
									}
									?>
									</label>
								</div>
								<div class="btn_uplimg_right"></div>
							</div>
						</div>	
						
					</div>
					
					<div class="inner_round_box">
						<script type="text/javascript" src="<?php echo $base_url;?>js/jHtmlArea/scripts/jquery-ui-1.7.2.custom.min.js"></script>
						<link rel="Stylesheet" type="text/css" href="<?php echo $base_url;?>js/jHtmlArea/style/jqueryui/ui-lightness/jquery-ui-1.7.2.custom.css" />
						<script type="text/javascript" src="<?php echo $base_url;?>js/jHtmlArea/scripts/jHtmlArea-0.7.0.js"></script>
						<link rel="Stylesheet" type="text/css" href="<?php echo $base_url;?>js/jHtmlArea/style/jHtmlArea.css" />
						<script type="text/javascript" src="<?php echo $base_url;?>js/jHtmlArea/scripts/jHtmlArea.ColorPickerMenu-0.7.0.js"></script>
						<link rel="Stylesheet" type="text/css" href="<?php echo $base_url;?>js/jHtmlArea/style/jHtmlArea.ColorPickerMenu.css" />
						<style type="text/css">
							/* body { background: #ccc;} */
							div.jHtmlArea .ToolBar ul li a.custom_disk_button 
							{
								background: url('<?php echo $base_url;?>js/jHtmlArea/images/disk.png') no-repeat;
								background-position: 0 0;
							}
							
							div.jHtmlArea { border: solid 1px #ccc; }
						</style>
						<script type="text/javascript">    
						$(function() {
							$("#pro_description").htmlarea({
								// Override/Specify the Toolbar buttons to show
								toolbar: [
								    ["bold", "italic", "underline", "|", "forecolor"],
								    ["increaseFontSize", "decreaseFontSize"],
								    ["p", "h1", "h2", "h3", "h4", "h5", "h6"],
								    ["justifyleft", "justifycenter", "justifyright"]
								]
							});
						});
						</script>
						<div class="form_field_big">
							<b>Description of your listing. The more information the better</b><br />
							<label for="pro_description" id="lblpro_description">Describe your listing</label><br /><br />
							<textarea name="pro_description" id="pro_description"  cols="70" rows="15" style="width:650px;" class="inputbg"><?php echo $rowSelPro['product_description']; ?></textarea>
						</div>
					</div>
					
					<div class="inner_round_box">
						<div class="form_field_big">
							<b>Choose how you want to sell your products</b><br />
							<label for="pro_price" id="lblpro_price">Price</label>
							<label for ="bargin_off" style="width:120px">Bargain Price Option</label>
							<sup><a href="javascript:void(0);" id="bargain_price_more_info" onclick="show_more_info(1)">more info <img align="absmiddle" src="images/small_yellow_star.jpg" style="border:0px" /></a></sup>
							<div style="float:left; width:95%;">
								<input type="text" style="width:80px; float:left;" name="pro_price" id="pro_price" value="<?php echo "$".number_format($rowSelPro['product_price'],2);?>" class="inputbg" onchange="projected_profit()" onblur="format_value('pro_price')" onFocus="clearIndicator(this,'$')" onClick="clearIndicator(this,'$')"  />
				<?php /*?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php */?>
								<img src="images/on_big_03.png" align="absmiddle" id="bargin_on" alt="ON" onclick="toggle_bargain_img(1)" style="margin:0px 0px 0px 65px;"  /> &nbsp;OR&nbsp;
								<img src="images/off_small_07.png" align="absmiddle" id="bargin_off" style="cursor:pointer;" onclick="toggle_bargain_img(0)" alt="OFF" />
								<input type="hidden" name="bargain_price_option" id="bargain_price_option" value="<?php echo $rowSelPro['bargain_price_option'];?>" class="inputbg" style=" float:left;" />
								<script>
									function toggle_bargain_img(a)
									{
										if(a==0)
										{
											$('#bargin_on').attr({src: "images/on_small_07.png", title: "ON", alt: "ON"});
											$('#bargin_on').css('cursor','pointer');
											$('#bargin_off').attr({src: "images/off_big_03.png", title: "OFF", alt: "OFF"});
											$('#bargin_off').css('cursor','default');
										}
										else
										{
											$('#bargin_on').attr({src: "images/on_big_03.png", title: "ON", alt: "ON"});
											$('#bargin_on').css('cursor','default');
											$('#bargin_off').attr({src: "images/off_small_07.png", title: "OFF", alt: "OFF"});
											$('#bargin_off').css('cursor','pointer');
										}
										$('#bargain_price_option').val(a);
									}
								</script>
								<span style="float:left; color:red; width:100px; display:none;" id="digit_err1">Digits Only</span>
							</div>
						</div>
						
						<div class="form_field_big">
							<label for="pro_courior" id="lblpro_courior">Shipping Service</label><br /><br />
							<select name="pro_courior" id="pro_courior" style="width:150px; float:left" class="inputbg">										
								<option value=''>Select</option>
								<?php 		
								$qry="SELECT * FROM tbl_shipping_service";
								$res=mysql_query($qry);
								if(mysql_num_rows($res) > 0)
								{
								?>
													
								<?php				
									while($row = mysql_fetch_assoc($res))
									{
									?>				
										<option value="<?php echo $row['shipping_id'] ?>"><?php echo $row['shipping_name'];?></option>
									<?php		
									}
									?>
							<?php
								}						
								?>																	
							</select><script>$('#pro_courior').val(<?php echo $rowSelPro['courior_id']; ?>);</script>
						</div>
						
						 
						
						<div class="form_field_big">
							<label for="pro_ship">Shipping cost</label><br /><br />
							
							<input type="text" style="width:80px; float:left;"  class="inputbg" name="pro_ship" id="pro_ship"  onchange="projected_profit()" value="<?php if($rowSelPro['shipping']=='Free') echo ''; else echo "$".number_format($rowSelPro['shipping'],2);?>"  onblur="format_value('pro_ship')"  onFocus="clearIndicator(this,'$')" onClick="clearIndicator(this,'$')" />
							
							<div style="float:left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
							
							<input type="checkbox" style="width:auto; float:left;" name="ship_status" id="ship_status"  onclick="funcheckShip()" value="1" class="inputbg" />
							<label for="ship_status" style="width:100px;">Free Shipping</label>
							<input type="checkbox" style="width:auto; float:left;" name="localPickup" id="localPickup" value="1" class="inputbg" />
							<label for="localPickup" style="width:100px;">Free Local Pickup</label>
							<sup><a href="javascript:void(0);" id="local_pickup_more_info" onclick="show_more_info(2)">more info <img align="absmiddle" src="images/small_yellow_star.jpg" style="border:0px" /></a></sup>
							<?
							if($rowSelPro['shipping']=='Free') {
								?>
								<script>$("#ship_status").attr('checked','checked'); $('#pro_ship').attr('disabled','disabled');</script>
								<?
							}
							
							if($rowSelPro['localPickup']=='1') {
								?>
								<script>$("#localPickup").attr('checked','checked');</script>
								<?
							}
							?>
							<span style="float:left; color:red; width:100px; display:none;" id="digit_err2">Digits Only</span>
						</div>
						
						<?php /* 
						<div class="form_field_big">
							<label for="remarks">Shipping Time</label><br /><br />
							<select name="pro_shipping" id="pro_shipping" style="width:84px;">										
								<option value=''>..Select..</option>
								<?php 		
								$qry="SELECT * FROM tbl_handling_time";
								$res=mysql_query($qry);
									if(mysql_num_rows($res) > 0)
									{
									?>
														
									<?php				
										while($row = mysql_fetch_assoc($res))
										{
										?>				
											<option value="<?php echo $row['handling_time_id'] ?>"><?php echo $row['handling_time_name'];?></option>
										<?php		
										}
										?>
								<?php
									}						
								?>																	
							</select>
						</div>
						      */ ?>
						
						<div class="form_field_big">
							<label for="pro_commission" style="width:100px;" id="lblpro_commission">Commission</label>&nbsp;&nbsp;<sup style="float:left;"><a href="javascript:void(0);" id="commission_more_info" onclick="show_more_info(3)">more info <img align="absmiddle" src="images/small_yellow_star.jpg" style="border:0px" /></a></sup>
							<label for ="bargin_c_off" style="width:260px; margin:0px 0px 0px 15px;">Bargain Commission Option&nbsp;&nbsp;<sup><a href="javascript:void(0);" id="bargain_commission_more_info" onclick="show_more_info(4)">more info <img align="absmiddle" src="images/small_yellow_star.jpg" style="border:0px" /></a></sup></label>
							
							<div style="float:left; width:95%;">
								<input type="text" style="width:80px; float:left;" name="pro_commission" id="pro_commission" class="inputbg" onchange="$('#pc').html(this.value);" value="<?php echo "$".number_format($rowSelPro['commission'],2);?>" onblur="format_value('pro_commission')" onFocus="clearIndicator(this,'$')" onClick="clearIndicator(this,'$')"   />
								
								
<?php /*?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	<?php */?>							
								<img src="images/on_big_03.png" align="absmiddle" id="bargin_c_on" alt="ON" onclick="toggle_bargain_c_img(1)" style="margin:0px 0px 0px 125px; cursor:pointer;"  /> &nbsp;OR&nbsp;
								<img src="images/off_small_07.png" align="absmiddle" id="bargin_c_off" style="cursor:pointer;" onclick="toggle_bargain_c_img(0)" alt="OFF" />
								<input type="hidden" name ="bargain_commission_option" id="bargain_commission_option" value="<?php echo $rowSelPro['bargain_commission_option'];?>" class="inputbg" style=" float:left;" />
								<script type="text/javascript">
								function toggle_bargain_c_img(a)
								{
									if(a==0)
									{
										$('#bargin_c_on').attr({src: "images/on_small_07.png", title: "ON", alt: "ON"});
										$('#bargin_c_on').css('cursor','pointer');
										$('#bargin_c_off').attr({src: "images/off_big_03.png", title: "OFF", alt: "OFF"});
										$('#bargin_c_off').css('cursor','default');
									}
									else
									{
										$('#bargin_c_on').attr({src: "images/on_big_03.png", title: "ON", alt: "ON"});
										$('#bargin_c_on').css('cursor','default');
										$('#bargin_c_off').attr({src: "images/off_small_07.png", title: "OFF", alt: "OFF"});
										$('#bargin_c_off').css('cursor','pointer');
									}
									$('#bargain_commission_option').val(a);
								}
								</script>
							</div>
						</div>
						
						<div class="form_field_big">
							<label for="pro_quantity" id="lblpro_quantity">Quantity</label><br /><br />
							
							<input type="text" style="width:80px; float:left;" name="pro_quantity" id="pro_quantity" class="inputbg" value="<?php echo $rowSelPro['quantity']; ?>" />
							
						</div>
						
						<?php /*if($userType=='2' || $userType=='4')
						{ 
							if($_GET['by']=='own')
							{
								echo "<input type='hidden' name='sell_by' value='1'>";
								?>
								<div class="form_field_big">
									<label for="pro_duration">Duration</label><br /><br />
									<select name="pro_duration" id="pro_duration" style="width:84px;">										
										<option value='3'>3 days</option>
										<option value='5'>5 days</option>
										<option value='7' selected>7 days</option>
										<option value='10'>10 days</option>						
									</select> (Listing started immediately)
									<script>$('#pro_duration').val(<?php echo $rowSelPro['duration'];?>)</script>
								</div>
								<?php
							}
							else if($_GET['by']=='seller') {
							      echo "<input type='hidden' name='sell_by' value='0'>";
							}
							else
							{
								?>
								<div class="form_field_big">
									<label for="sell_by">Sell by</label><br /><br />
									<div id="sellby-div">
										<label>Seller</label><input type="radio" name="sell_by" id="sell_by_seller" value="0" checked />					  
										<label>Owner</label><input type="radio" name="sell_by" id="sell_by_owner" value="1" />
										  
									</div>
								</div>
			   
						<?php	} 
						}
						else {
							echo "<input type='hidden' name='sell_by' value='0'>";
						} */
						?>
						
						<div class="form_field_big">
							<label for="pro_condition" id="lblpro_condition">Condition</label><br /><br />
							<select name="pro_condition" id="pro_condition" style="width:174px; float:left;" class="inputbg">										
								<option value=''>Select</option>
								<option value="New">New</option>
								<option value="New (package open)">New (package open)</option>
								<option value="Manufacturer Refurbished">Manufacturer Refurbished</option>
								<option value="For parts not working">For parts not working</option>
								<option value="Original, Reproduction">Original, Reproduction</option>
								<option value="Seller Refurbished">Seller Refurbished</option>
								<option value="Used">Used</option>																
							</select>
							<script>$('#pro_condition').val('<?php echo $rowSelPro['pro_condition'];?>')</script>
						</div>
						
						<div class="form_field_big">
							<label for="sale_tax" style="width:260px;">Sales Tax (if applicable) &nbsp;&nbsp;&nbsp;<sup ><a href="javascript:void(0);" id="sales_tax_more_info" onclick="show_more_info(5)">more info <img align="absmiddle" src="images/small_yellow_star.jpg" style="border:0px" /></a></sup></label><br /><br /><br />
								
							
									
							<?php 		
							$qry="SELECT * FROM tbl_state where country_id='213'";
							$res=mysql_query($qry);
							if(mysql_num_rows($res) > 0)
							{
								while($row = mysql_fetch_assoc($res))
								{
									$options.='<option value="'.$row['stateid'].'">'.$row['statename'].'</option>';
								}
							}
							?>
							<select name="state" id="state" style="width:145px; margin-right:10px; float:left;" class="inputbg"><?php echo $options; ?></select>&nbsp;&nbsp;
							
							<input type="text" name="sales_tax" id="sales_tax" onblur="javascript:return MaskMoney(event);format_value('sales_tax');" class="inputbg" value="<?php echo $rowSelPro['sales_tax'];?>" style="float:left; width:100px;" />
							 %
							
						</div>
						
						<div class="form_field_big">
							<label for="pro_policy" id="lblpro_policy">Return Policy</label><br /><br />
							<select name="pro_policy" id="pro_policy" style="width:150px; float:left;" class="inputbg">										
								<option value='Accept Returns'>Accept Returns</option>
								<option value="Don't Accept Returns">Don't Accept Returns</option>
							</select><br /><br /><br />
							
							<script>$('#pro_policy').val('<?php echo sanitize($rowSelPro['return_id']);?>')</script>
							<textarea name="remarks" id="remarks" style="height:40px; font-size:12px; float:left;" class="inputbg"><?php echo $rowSelPro['remarks'];?></textarea>
						</div>
						
						
						
						<div class="form_field_big">
							<label style="width:320px;" for="amazon_name">Amazon Receiving Funds Account &nbsp;&nbsp;&nbsp;<sup><a href="javascript:void(0);" id="amazon_more_info" onclick="show_more_info(6)">more info <img align="absmiddle" src="images/small_yellow_star.jpg" style="border:0px" /></a></sup></label><br /><br /><br />
							
							<input type="text" style="width:220px; float:left;" name="amazon_name" id="amazon_name" class="inputbg" value="<?php echo $amazonaccnt;?>" />
							&nbsp; Dont have one yet? Sign Up <a href="http://www.amazon.com">here</a>
						</div>
						
						<div class="form_field_big">
							<span style=" cursor:pointer; width:25px; float:left; " id="plus_minus" onclick="show_hide_pro_key()"><img src="<?php echo $base_url?>images/plus_ico.png" id="pm" align="absmiddle" /></span> <label>Product Key</label><br /><br />
						</div>
						
						<div class="form_field_big" style="display:none;" id="prokeybox">
							<div class="row_to_clone" id="divReplica" style="float:left; width:700px;">
								<label for="pro_quantity">Product Key</label><br /><br />
								<input type="text" name="code[0]" id="code[0]" class="inputbg" maxlength="10"  size="10" value="<?php echo $first_value; ?>" onblur="javascript:return checkAvailability(this.value,getRef('pro_quantity').value,this,<?php echo $proId;?>);"  style="float:left;" />
								<span id="msg[0]" name="msg[0]" class="error" style="margin-top:15px; float:left;">Please enter the 10 digit code</span>
							</div>
						</div>
						<script>
						function show_hide_pro_key()
						{
							if($('#prokeybox').is(':visible') ) {
								$('#prokeybox').hide();
								$('#plus_minus').html('<img src="<?php echo $base_url?>images/plus_ico.png" id="pm" align="absmiddle" />');
							}
							else
							{
								$('#prokeybox').show();
								$('#plus_minus').html('<img src="<?php echo $base_url?>images/minus_ico.png" id="pm" align="absmiddle" />');
							}
						}
						</script>
					</div>
					
					<div class="inner_round_box">
						<div class="form_field_big">
							<b>OPTIONAL - Free gift with purchase. An extra incentive always helps.</b><br />
							<label for="gift_name">Gift Name</label><br /><br />
							
							<input type="text" name="gift_name" id="gift_name" class="inputbg" value="<?php echo $rowSelPro['gift_name'];?>" style="float:left;" />
							
						</div>
						
						<div class="form_field_big">
							<label for="gift_description">Free Gift Desciption</label><br /><br />
							<textarea name="gift_description" id="gift_description" style="height:70px; width:500px;  font-size:12px; float:left;" class="inputbg"><?php echo $rowSelPro['gift_description'];?></textarea>
						</div>
						
						<div class="form_field_big">
							<label for="remarks">Free Gift Image</label><br /><br />
							
							<label for="gift_image">Gift Image</label><br /><br /><br />
							<input type="file" name="gift_image" id="gift_image" style="float:left;" class="inputbg" />
							
						</div>
						<?
							if(!empty($rowSelPro['gift_image']))
							{
								$img6 = explode("/",$rowSelPro['gift_image']);
								$img6 = $img6[2];
							}
							else
							{
								$img6 = ''; 
							}
							
							?>
						<div class="form_field_big">
							<div style="float:left; width:50px;">&nbsp;</div><!--This div is to give some blank space before button 1 starts-->
							<div style="float:left; margin-bottom:-10px; margin-right:10px;">
								<div class="btn_uplimg_left"></div>
								<div class="btn_uplimg_repeat">
									<label style="width:100px; text-align:center; font-weight:bold; margin-top:5px;">Image 1
									<?
									if(!empty($rowSelPro['gift_image']))
									{
									?>
										<img src="images/success.gif" align="absmiddle" />
									<?
									}
									?>
									</label>
									
								</div>
								<div class="btn_uplimg_right"></div>
							</div>
						</div>
					</div>
					
					<div class="inner_round_box">
						<div class="form_field_big">
							<b>Fees and Profit Breakdown</b><br />
							<div style="float:left; width:250px; margin:10px 0px 10px 50px;">
								<div style="float:left; width:150px; text-align:left;">Product Price</div>
								<div style="float:left; width:100px; text-align:right;">$ <span id="pp">0.00</span></div>
								<div style="float:left; width:150px; text-align:left;">Listing Fee</div>
								<div style="float:left; width:100px; text-align:right;">$ <span id="lf">0.00</span></div>
								<div style="float:left; width:150px; text-align:left;">Images Fee</div>
								<div style="float:left; width:100px; text-align:right;">$ <span id="if">0.00</span></div>
								<div style="float:left; width:150px; text-align:left;">Commission Offered</div>
								<div style="float:left; width:100px; text-align:right;">$ <span id="pc">0.00</span></div>
								<div style="float:left; width:200px;">&nbsp;</div>
								<div style="float:left; width:150px; text-align:left;">Swapen Charges</div>
								<div style="float:left; width:100px; text-align:right;"><span id="sc">3</span>%</div>
								<div style="float:left; width:250px;"><hr /></div>
								<div style="float:left; width:150px; text-align:left; color:#b5b5b5;">Projected Profit</div>
								<div style="float:left; width:100px; text-align:right; color:red;"><span id="prp"><b>$0.00</b></span></div>
							</div>
						</div>
						
					</div>
					
					<div class="form_field_big">
						<div style="margin-left: 200px;" class="checkbox"><input type="checkbox" name="i_agree" id="i_agree" class="inputbg" style="float:left;" /></div> I agree that:
						
						<div style="float: left; width: 95%; margin-top: 20px;">
							<ul style="float: left; margin-left: 200px;">
							    <li>I accept the User Agreements and Privacy Policy</li>
							    <li>I may recieve communications from swapen</li>
							    <li>I am atleast 18 years old</li>
							</ul>
						</div>
						<div id="errMsg" style="float:left; width:100%;" align="center"></div>
					</div>
					
					<div align="center" class="form_field_big">
						<input type="hidden" name="keyword" id="keyword" value="<?php echo $_GET['editlist'];?>" >
						<input type="submit" name="submit" id="submit" value="Submit Listing" class="sbmt_btn" />
					</div>
					
				</div>
				<div class="fullbox2_bot"></div>
			</div>
		</form>
	</tr>
</table>
</div>
<div style=" display: none; width: 400px; font-weight:bold; padding:10px; background-color:#cccccc;" class="user_popup" id="more_info">
	<span style="float:left; width:100%; text-align:right; margin-bottom:5px;"><label style="cursor:pointer;" onclick="$('#more_info').fadeOut('slow');">x</label></span>
	<span style="float:left; width:100%; margin-bottom:10px;" id="desc_info_n"></span>
</div>
<script language="javascript" type="text/javascript">
addRowsWithValue(<?php echo $rowSelPro['quantity']; ?>,'<?php echo $rowSelCodes['Codes']; ?>');
add_Sold(<?php echo $rowSelPro['quantity']; ?>,'<?php echo $rowSelCodes['Sold']; ?>');
</script>
<script language="javascript" type="text/javascript">
function onlyint(event,a) {
	
	var charCode = event.keyCode || event.which;
	if(event.shiftKey && charCode == 9)
	{return true}
	else  if (event.shiftKey)
	{	$('#digit_err'+a).show().fadeOut("slow"); return false;	}
	else if  (((event.keyCode == 46) || (event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105) || (event.keyCode == 8) || (event.keyCode == 9)) )
	{ return true; } else { $('#digit_err'+a).show().fadeOut("slow"); return false; }
}
function projected_profit()
{
	var pro_price 	= $('#pro_price').val();
	
	var pro_ship = $('#pro_ship').val();
	var pro_comission = $('#pro_commission').val();
	
	if(pro_price=='$')
		pro_price=0.00;
	else
	{
		//alert(pro_price);
		var i 		= pro_price.indexOf('$');
		if(i!=-1)
		{
			var temp1	= pro_price.split('$');
			pro_price	= temp1[1];
		}
		
	}
	
	if(pro_ship=='$' || pro_ship=='Free')
		pro_ship=0.00;
	else
	{
		var j 		= pro_ship.indexOf('$');
		if(j!=-1)
		{
			var temp2	= pro_ship.split('$');
			pro_ship	= temp2[1];
		}
	}
	
	if(pro_comission=='$')
		pro_comission=0.00;
	else
	{
		var k 		= pro_comission.indexOf('$');
		if(k!=-1)
		{
			var temp3	= pro_comission.split('$');
			pro_comission	= temp3[1];
		}
	}
	
	
	
		
	var product_price = parseFloat(pro_price) + parseFloat(pro_ship);
	
	
	if(pro_ship=='$' || pro_ship=='Free')
	{
		if(pro_price!='$') {
			$('#pp').html(parseFloat(pro_price).toFixed(2));
			pro_ship = 0.00;
		}
	}
	else {
		$('#pp').html(parseFloat(product_price).toFixed(2));
		
	}
	$('#pc').html(pro_comission);
	var percnAmt = parseFloat(product_price)*0.03;
	var projectedAmt = parseFloat(product_price) - parseFloat(percnAmt);
	
	
	
	$('#prp').html('<b>$'+projectedAmt.toFixed(2)+'</b>');
}



function validateForm()
{
	var flag=0;
	if($('#pro_subcategory').val()=='')
	{
		flag=flag+1;
		$('#lblpro_subcategory').css({'font-weight':'bold','color':'#FF0000'});
	}
	else {
		$('#lblpro_subcategory').css({'font-weight':'normal','color':'#666666'});
	}
	
	if($('#pro_sub_subcategory').val()=='')
	{
		flag=flag+1;
		$('#lblpro_sub_subcategory').css({'font-weight':'bold','color':'#FF0000'});
	}
	else {
		$('#lblpro_sub_subcategory').css({'font-weight':'normal','color':'#666666'});
	}
	
	if($('#pro_name').val()=='')
	{
		flag=flag+1;
		$('#lblpro_name').css({'font-weight':'bold','color':'#FF0000'});
	}
	else {
		$('#lblpro_name').css({'font-weight':'normal','color':'#666666'});
	}
	
	if($('#pro_description').val()=='')
	{
		flag=flag+1;
		$('#lblpro_description').css({'font-weight':'bold','color':'#FF0000'});
	}
	else {
		$('#lblpro_description').css({'font-weight':'normal','color':'#666666'});
	}
	
	if($('#pro_price').val()=='')
	{
		flag=flag+1;
		$('#lblpro_price').css({'font-weight':'bold','color':'#FF0000'});
	}
	else {
		$('#lblpro_price').css({'font-weight':'normal','color':'#666666'});
	}
	
	if($('#pro_commission').val()=='')
	{
		flag=flag+1;
		$('#lblpro_commission').css({'font-weight':'bold','color':'#FF0000'});
	}
	else {
		$('#lblpro_commission').css({'font-weight':'bold','color':'#666666'});
	}
	if($('#pro_quantity').val()=='' || !Number($('#pro_quantity').val()))
	
	{
		flag=flag+1;
		$('#lblpro_quantity').css({'font-weight':'bold','color':'#FF0000'});
	}
	else {
		$('#lblpro_quantity').css({'font-weight':'bold','color':'#666666'});
	}
	
	
	if($('#pro_courior').val()=='')
	{
		flag=flag+1;
		$('#lblpro_courior').css({'font-weight':'bold','color':'#FF0000'});
	}
	else {
		$('#lblpro_courior').css({'font-weight':'normal','color':'#666666'});
	}
	if($('#pro_condition').val()=='')
	{
		flag=flag+1;
		$('#lblpro_condition').css({'font-weight':'bold','color':'#FF0000'});
	}
	else {
		$('#lblpro_condition').css({'font-weight':'normal','color':'#666666'});
	}
	if($('#pro_policy').val()=='')
	{
		flag=flag+1;
		$('#lblpro_policy').css({'font-weight':'bold','color':'#FF0000'});
	}
	else {
		$('#lblpro_policy').css({'font-weight':'normal','color':'#666666'});
	}
	
	if($("#i_agree").is(":checked")==false)
	{
		flag=flag+1;
		alert('You have to agree our conditions before submiting your data.');
	}
	
	if(flag>0)
	{
		$('#errMsg').html("<font color='#FF0000'><b>We need some additional information from you. Enter valid information in red color highlighted fields and try again.</b></font>");
		return false;
	}
	else
	{
		$('#errMsg').html('');
		return true;
	}
}

function MaskMoney(evt) 
    {
	
    if (!(evt.keyCode == 46 || (evt.keyCode >= 48 && evt.keyCode <= 57))) return false;
    var parts = evt.srcElement.value.split('.');
    if (parts.length > 2) return false;
    if (evt.keyCode == 46) return (parts.length == 1);
    if (parts[0].length >= 14) return false;
    if (parts.length == 2 && parts[1].length >= 2) return false;
    }

function show_login() {
	var pos = $('#submitbutton').position();
	var nleft = parseInt(pos.left)-130;
	var ntop = parseInt(pos.top)+28;
	$('#login_box').css({'left': 400, 'top':2520});
	$('#login_box').fadeIn('slow');
}
function validateLogin()
  {
   // alert('hi');
    var username = $('#username').val();
    var password = $('#password').val();
    $('#login_error').html('');
    if(username=='' || password=='')
    {
      alert('Please enter username and password');
    }
    else
    {
      //alert('hi');
      var url = "<?php echo $base_url;?>ajax_signin.php";
      $.post(url,
      { 'username': username, 'password':password},
      function(data)
      {
	//alert(data);
	if(data=='Your account is on hold, please contact us for more information')
	  $('#login_error').html(data);
	else if(data=='Your Account has been placed on the inactive list, please contact Swapen Support')
	  $('#login_error').html(data);
	else if(data=='Invalid user name and password.')
	  $('#login_error').html(data);
	else if(data=='')
	  window.location='index.php';
	else
	  window.location='index.php?'+data;
	      
      },
      'html'
      );
    }
  }

//function for saving in draft table
function save_to_draft()
{
	var pro_subcategory = $('#pro_subcategory').val();
	var pro_sub_subcategory = $('#pro_sub_subcategory').val();
	var pro_name = $('#pro_name').val();
	var pro_description = $("#pro_description").htmlarea("toHtmlString");
	var pro_price = $('#pro_price').val();
	var bargain_price_option = $('#bargain_price_option').val();
	var pro_courior = $('#pro_courior').val();
	var pro_ship = $('#pro_ship').val();
	var ship_status = $('#ship_status').val();
	var localPickup = $('#localPickup').val();
	var pro_commission = $('#pro_commission').val();
	var bargain_commission_option = $('#bargain_commission_option').val();
	var pro_quantity = $('#pro_quantity').val();
	var pro_condition = $('#pro_condition').val();
	var sales_tax = $('#sales_tax').val();
	var pro_policy = $('#pro_policy').val();
	var remarks = $('#remarks').val();
	var amazon_name = $('#amazon_name').val();
	var gift_name = $('#gift_name').val();
	var gift_description = $('#gift_description').val();
	var page = 'sell_product';
	var user_id = '<?php echo $_SESSION['user_id_sess'];?>';
	
	var url = "<?php echo $base_url;?>ajax_drafts.php";
	$.post(url,
	{ 'user_id':user_id,'page':page,'pro_subcategory': pro_subcategory, 'pro_sub_subcategory':pro_sub_subcategory, 'pro_name':pro_name,'pro_description':pro_description,'pro_price':pro_price,'bargain_price_option':bargain_price_option,'pro_courior':pro_courior,'pro_ship':pro_ship,'ship_status':ship_status,'localPickup':localPickup,'pro_commission':pro_commission,'bargain_commission_option':bargain_commission_option,'pro_quantity':pro_quantity,'pro_condition':pro_condition,'sales_tax':sales_tax,'pro_policy':pro_policy,'remarks':remarks,'amazon_name':amazon_name,'gift_name':gift_name,'gift_description':gift_description},
	function(data)
	{
		var temp = data.split('###');
		if(temp[1]=='succ')
		{
			$('#draft_box').html(temp[0]).show();
			alert("Saved to Drafts Successfully");
		}
		else
			alert("Sorry! Could not save at this time.");
	},
	'html');
}


function applyDraft(draft_id)
{
	//alert('hi');
	var url = "<?php echo $base_url;?>ajax_get_drafts.php";
	$.post(url,
	{ 'draft_id':draft_id},
	function(data)
	{
		//alert('hi');
		if(data!='')
		{
			var temp = data.split('###');
			
			
			if(temp[19]!=1)
			{
				$('#pro_subcategory').val(temp[19]);
				
				getSubSubCat(temp[19],'sub-sub-category');
				setTimeout('$("#pro_sub_subcategory").val('+temp[0]+')',3000);
			}
			else
			{	
				$('#pro_subcategory').val(temp[0]);
				getSubSubCat(temp[19],'sub-sub-category');
			}
			
			$('#pro_name').val(temp[1]);
			$("#pro_description").htmlarea("pasteHTML", temp[2]);
			$('#pro_price').val(temp[3]);
			$('#bargain_price_option').val(temp[4]);
			toggle_bargain_img(temp[4]);
			
			$('#pro_courior').val(temp[5]);
			$('#pro_ship').val(temp[6]);
			$('#ship_status').val(temp[7]);
			$('#localPickup').val(temp[8]);
			$('#pro_commission').val(temp[9]);
			$('#bargain_commission_option').val(temp[10]);
			toggle_bargain_c_img(temp[10]);
			
			$('#pro_quantity').val(temp[11]);
			$('#pro_condition').val(temp[12]);
			//alert(temp[13]);
			$('#sales_tax').val(temp[13]);
			$('#pro_policy').val(temp[14]);
			$('#remarks').val(temp[15]);
			$('#amazon_name').val(temp[16]);
			$('#gift_name').val(temp[17]);
			$('#gift_description').val(temp[18]);
			
			
			projected_profit();
		}
	},
	'html');
}



</script>